<template>
	<w-layout showNavbar navTitle="口令详情" :navTitleColor="publicStyles['--color-t1']" background="url('/static/image/bk.png') no-repeat"
		navBackgroundColor="transparent" :scrollTop="page.scrollTop" :navScrollColor="publicStyles['--color-bk']">
		<template #default>
			<view class="container">
				<view class="">
					<view class="public-card-2 px-50 py-50 mt-40">
						<view class="fr-ac-jsb">
							<view class="fs-32">
								{{state.result.nickname}}发出的红包共计<text class="color">{{state.result.total_money}}</text>精粹
							</view>
						</view>
						<view class="fr-ac-jsb mt-30">
							<view class="">
								还有<text class="color">{{state.result.stock}}</text>个红包未领取
							</view>
							<view v-if="state.result.password" @click="copy(state.result.password)" class="fr-ac">
								<view class="mr-20 op-70">
									口令 {{state.result.password}}
								</view>
								<image style="width: 26rpx;height: 26rpx;" src="/static/icon/public/copy-fill.png" mode="widthFix"></image>
							</view>
						</view>
					</view>
				</view>
				<view class="public-box-4 px-50 py-50 mt-40" style="height: 1100rpx;overflow: scroll;">
					<view class="color fs-36">
						领取列表
					</view>
					<view class="mt-40 u-border-bottom pb-30 fr-ac" style="border-color: var(--gray-line) !important;" v-for="(item,index) in state.list" :key="index">
						<image style="width: 80rpx;height: 80rpx;border-radius: 50%;" :src="item.headimg" mode=""></image>
						<view class="flex-1 mx-20">
							<view class="ellipsis-1">
								{{item.nickname}}
							</view>
							<view class="mt-10 op-70">
								{{item.addtime}}
							</view>
						</view>
						<view class="color fs-32">
							{{item.money}}
						</view>
					</view>
					<no-more :show="state.list.length == 0"></no-more>
				</view>
			</view>
		</template>
	</w-layout>
</template>

<script setup>
	import{
		copy
	} from '@/common/common'
	import {
		ref,
		reactive,
		onMounted,
		computed,
		nextTick
	} from 'vue'
	import {
		storeToRefs
	} from 'pinia'
	import {
		onLoad, onPageScroll
	} from '@dcloudio/uni-app'
	import {
		useAppStore
	} from '@/store/app'
	import {
		useColorStore
	} from '@/store/color'
	import {
		red_envelope_detail
	} from '@/utils/request/api';
	import {
		useUserStore
	} from '@/store/user'
	const userStore = useUserStore()
	const appStore = useAppStore()
	const colorStore = useColorStore()
	const {
		publicStyles
	} = storeToRefs(colorStore)
	onLoad(async(options) => {
		if(options.id){
			state.red_envelope_id = options.id
			get_red_envelope_detail()
		}
	})
	onMounted(() => {
		appStore.loadingHandler(false)
	})
	onPageScroll((e)=>{
		page.scrollTop = e.scrollTop
	})
	const page = reactive({
		scrollTop:0
	})
	
	
	const state = reactive({
		list:[],
		page:1,
		limit:15,
		last_limit:15,
		
		red_envelope_id:'',
		result: {}
	})
	function initData(){
		state.list = []
		state.page = 1
		state.last_limit = 15
	}
	
	async function get_red_envelope_detail(){
		const res = await red_envelope_detail({
			red_envelope_id: state.red_envelope_id
		})
		state.result = res.result
		state.list = res.record.list
	}
</script>

<style lang="scss">
	.shadow {
		box-shadow: 2rpx 2rpx 12rpx var(--shadow);
	}
	.color{
		color: var(--color);
	}

	.container {
		width: 100%;
		min-height: 100%;
		position: relative;
		overflow: hidden;
		box-sizing: border-box;
		padding: 0 30rpx;
		
	}
</style>